//
//  RechargeCardTableVeiwCell.m
//  HWZB
//
//  Created by 许成雄 on 2017/4/20.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "RechargeCardTableViewCell.h"
#import "UIButton+Webcache.h"
#import "UIImageView+Webcache.h"

@interface RechargeCardTableViewCell()

@property (strong, nonatomic) UIView *bgView;
@property (strong, nonatomic) UIImageView *pictureImageView;

@end

@implementation RechargeCardTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(TRANS_VALUE(5.0f), TRANS_VALUE(5.0f), SCREEN_WIDTH - 2 * TRANS_VALUE(5.0f), TRANS_VALUE(92.0f))];
        self.bgView.backgroundColor = I_COLOR_WHITE;
        self.bgView.clipsToBounds = YES;
        self.bgView.layer.cornerRadius = TRANS_VALUE(6.0f);
        self.bgView.layer.borderColor = I_COLOR_DIVIDER.CGColor;
        self.bgView.layer.borderWidth = 1.0f;
        [self.contentView addSubview:self.bgView];
        
        self.pictureImageView = [[UIImageView alloc] initWithFrame:CGRectMake(TRANS_VALUE(5.0f), TRANS_VALUE(5.0f), SCREEN_WIDTH - 2 * TRANS_VALUE(10.0f), TRANS_VALUE(82.0f))];
        self.pictureImageView.contentMode = UIViewContentModeScaleToFill;
        [self.bgView addSubview:self.pictureImageView];
    }
    
    return self;
}

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setRechargeCardInfo:(CommodityInfo *)rechargeCardInfo {
    _rechargeCardInfo = rechargeCardInfo;
    if(_rechargeCardInfo) {
        NSString *imageURL = [NSString stringWithFormat:@"%@", _rechargeCardInfo.imageUrl];
        [self.pictureImageView sd_setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"ic_recharge_default"]];
    }
}


@end
